fn main() {
    //1.创建空的vector：Vec<T>

    let mut v:Vec<i32> = Vec::new();
    v.push(1);


    //2.创建包含初始值的vector
    let v = vec![1,2,3];

    //3.丢弃vector
    {
        let v1 = vec![1,2,3];
    }

    //4.读取元素

    let one = v[0];
    println!("one = {}",one);

    //rust推荐
    match v.get(1) {
        Some(value) => println!("value = {}",value),
        _ => println!("None")
    }

    //5.更新元素
    let mut v2 = Vec::new();
    v2.push(1);
    v2.push(2);
    v2.push(3);

    //6.遍历
    for i in v2{
        println!("i = {}",i);
    }

    //7. 使用枚举
    enum Context{
        Content(String),
        Length(i32),
    }
    impl Context{
        fn get_lenth(&self)->&i32{
            match &*self {
                Context::Length(lenth)=>lenth,
                _ => &0
            }
        }
    }

    let v3 = vec![
        Context::Content(String::from("xiaoming")),
        Context::Length(8)
    ];

    let mut v = vec![1,2,3];
    let first = v[0];
    println!("first1 = {}",first);
    v.push(4);
    println!("first2 = {}",first);

    for temp in v3 {
        println!("wwwwwwwwwwwww:{}",temp.get_lenth());
    }




    println!("Hello, world!");
}
